package day01_homework;

import java.util.Random;
import java.util.Scanner;

public class Test06 {
    public static void main(String[] args) {
        String randomX = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
        Random random = new Random();
        //random.nextInt(randomX.length());
        //System.out.println(randomX.charAt(random.nextInt(randomX.length())));
        String randomY = "";
        for (int i = 0; i < 5; i++) {
            randomY += String.valueOf(randomX.charAt(random.nextInt(randomX.length())));
        }
        System.out.println(randomY);
        System.out.println("请输入验证码：");
        Scanner sc = new Scanner(System.in);
        String input = sc.nextLine();
        boolean check = input.equalsIgnoreCase(randomY);
        if (check) {
            System.out.println("验证码正确");
        } else {
            System.out.println("验证码错误");
        }
    }
}
